global root "C:\Users\hanwa\Desktop\replication"

use "$root\data\IMC_HA_Yearly_Panel_clean.dta", replace

drop if startyear==-1
keep if cem_matched==1

gen bench_time= year-startyear
gen bench_time_0=bench_time ==0

foreach num of numlist 1(1)3{
gen bench_time_po`num'= bench_time == `num'
}

foreach num of numlist 1(1)3{
gen bench_time_pr`num'= bench_time == -`num' 
}

gen bench_time_pr4= bench_time<= -4
gen bench_time_po4= bench_time>= 4

drop bench_time
gen zero = 0 

global prepost bench_time_pr4 bench_time_pr3 bench_time_pr2 zero bench_time_0 bench_time_po1 bench_time_po2 bench_time_po3 bench_time_po4 

est clear
stackedev lnexpend $prepost, cohort(startyear) time(region_y) never_treat(no_treat) unit_fe(code) clust_unit(code) covariates (deficit_rate grant_dependence lnpop lnclaim lnwage  kids private umemploy pension vulnerable )
eststo f1

graph drop _all
coefplot f1 ///
,omitted keep(bench_time_pr4 bench_time_pr3 bench_time_pr2 zero bench_time_0 bench_time_po1 bench_time_po2 bench_time_po3 bench_time_po4)  /// 
vertical lcolor(gs6) mlcolor(gs6) mfcolor(gs6)  msize (*1.6) msymbol(Oh)  ///
legend(off) ///
scheme(s1mono) ///
graphregion(margin(5 9 5 5)) ///
xlabel( 1 "-4" 2 "-3" 3 "-2" 4 "-1" 5 "0" 6 "1" 7 "2" 8 "3" 9 "4") ///
ytitle("Net administrative cost", margin(0 1 4 0)) ///
xtitle(" ") ///
yline(0, lcolor(red) lwidth(*1.1)) ///
xline(5, lwidth(medium) lpattern(dash) lcolor(cranberry))
graph export "$root\figures\figure3.png", as(png) replace


